<template>
  <div>
    axios
  </div>
</template>
<script>
import axios from 'axios'
import { request } from '../../utils/requistAxios'
export default {
  name: 'axios',
  data() {
    return {

    }
  },
  created() {
    // axios(config)
    axios({
      url: 'http://123.207.32.32:8000/home/multidata',
      method: 'get'
    }).then(res => {
      console.log('get',res);
    }),
    axios({
      url: 'http://123.207.32.32:8000/home/data',
      // params 专门针对 get 请求参数拼接,data 专门针对 post
      params: {
        type: 'sell',
        page: 3
      },
      // method:'get'
    }).then(res => {
      console.log('post',res);
    }),



    // 2.发送并发请求
    axios.all([
      axios({
        url: 'http://123.207.32.32:8000/home/multidata',
      }),
      axios({
        url: 'http://123.207.32.32:8000/home/data?type=sell&&page=1',
      })
    ]).then(result => {
      console.log('并发请求',result);
    })

    // 3.封装的网络请求
    request({
      url: '/home/multidata'
    }).then(res => {
      console.log('封装的网络请求',res);
    }).catch(err => {
      console.log(err);
    })




  },
  mounted() { },
  methods: {
  },
}
</script>
<style lang="scss" scoped>

</style>
